#ifndef __WIZ_MEMORY_OBJECT_HPP__SHANHAOBO_19800429__
#define __WIZ_MEMORY_OBJECT_HPP__SHANHAOBO_19800429__

#include "../../Base/WizBase.hpp"

#ifdef new
#   undef new
#   warning "macro new"
#endif

#ifdef delete
#   undef delete
#   warning "macro delete"
#endif

namespace Wiz
{
    namespace Memory
    {
        namespace Object
        {
            template <class AllocatorT>
            class Type
            {
                typedef AllocatorT              tAllocator;
            public:
                explicit Type()
                { }
                ~Type()
                { }
            public:
                //////////////////////////////////////////////////////////////////////////
                ///=============================STANDARD ==============================///
                //////////////////////////////////////////////////////////////////////////
                void* operator new(size_t sz)
                {
                    return tAllocator::Allocate(sz);
                }
                void* operator new[](size_t sz)
                {
                    return tAllocator::AllocateArray(sz);
                }
                void operator delete(void* ptr)
                {
                    tAllocator::Deallocate(ptr);
                }

                void operator delete[](void* ptr)
                {
                    tAllocator::DeallocateArray(ptr);
                }
                //////////////////////////////////////////////////////////////////////////
                ///==============================STANDARD==============================///
                //////////////////////////////////////////////////////////////////////////

                //////////////////////////////////////////////////////////////////////////
                ///============================DEBUG INFO==============================///
                //////////////////////////////////////////////////////////////////////////
                /// with debug info
                void* operator new(size_t sz, const char* file, int line, const char* func)
                {
                    return tAllocator::AllocateWithDebugInfo(sz, file, line, func);
                }
                void* operator new[](size_t sz, const char* file, int line, const char* func)
                {
                    return tAllocator::AllocateArrayWithDebugInfo(sz, file, line, func);
                }

                // with debug info(only called if there is an exception in corresponding 'new')
                void operator delete(void* ptr, const char* file, int line, const char* func)
                {
                    tAllocator::DeallocateWithDebugInfo(ptr, file, line, func);
                }
                void operator delete[](void* ptr, const char* file, int line, const char* func)
                {
                    tAllocator::DeallocateArrayWithDebugInfo(ptr, file, line, func);
                }
                //////////////////////////////////////////////////////////////////////////
                ///============================DEBUG INFO==============================///
                //////////////////////////////////////////////////////////////////////////

                //////////////////////////////////////////////////////////////////////////
                ///============================PLACEMENT===============================///
                //////////////////////////////////////////////////////////////////////////
                /// placement operator new
                void* operator new(size_t, void* placement_ptr)
                {
                    return placement_ptr;
                }
                void* operator new[](size_t, void* placement_ptr)
                {
                    return placement_ptr;
                }

                /// placement operator new
                void operator delete(void* ptr, void*)
                {
                    //return ptr;
                }
                void operator delete[](void*, void* ptr)
                {
                    //return ptr;
                }
                //////////////////////////////////////////////////////////////////////////
                ///=========================PLACEMENT==================================///
                //////////////////////////////////////////////////////////////////////////
            };
        } /// end of namespace Object
    } /// end of namespace Memory
} /// end of namespace Wiz

#endif /*__WIZ_MEMORY_OBJECT_HPP__SHANHAOBO_19800429__*/
